using System.Collections.Generic;
using UnityEngine;
using Verse;

namespace RimWorld;

public class PlaceWorker_NeedsFuelingPort : PlaceWorker
{
	public override AcceptanceReport AllowsPlacing(BuildableDef def, IntVec3 center, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
	{
		if (FuelingPortUtility.FuelingPortGiverAtFuelingPortCell(center, map) == null)
		{
			return "MustPlaceNearFuelingPort".Translate();
		}
		return true;
	}

	public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
	{
		Map currentMap = Find.CurrentMap;
		List<Building> allBuildingsColonist = currentMap.listerBuildings.allBuildingsColonist;
		for (int i = 0; i < allBuildingsColonist.Count; i++)
		{
			Building building = allBuildingsColonist[i];
			if (building.def.building.hasFuelingPort && !Find.Selector.IsSelected(building) && FuelingPortUtility.GetFuelingPortCell(building).Standable(currentMap))
			{
				PlaceWorker_FuelingPort.DrawFuelingPortCell(building.Position, building.Rotation);
			}
		}
	}
}
